<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="sf" uri="http://www.springframework.org/tags/form" %>

<!DOCTYPE html>
<html>
    <head>
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/resources/css/admin/main.css"/>
<script type="text/javascript" src="<%=request.getContextPath() %>/resources/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/resources/js/core/jquery.cms.core.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/resources/js/admin/main.js"></script>
      
    </head>
    <body>
    <div id="content">
	<h3 class="admin_link_bar">
		<jsp:include page="inc.jsp"></jsp:include>
	</h3>
	<form action="<%=request.getContextPath() %>/admin/member_manage/add"  id="myform" method="post">
	<table width="800" cellspacing="0" cellPadding="0" id="listTable">
		<thead>
		<tr>
		<td colspan=2>添加用户</td>
		
		</tr>
		</thead>
		<tbody>
			        
			 			<tr>
			 			<td>姓名：</td><td><input type="text" name="realName"  id="name" onblur="checkname(this);"  maxlength=10/><font color="red"><span id="namespan"></span></font></td>
			 			</tr>
			 			<tr>
			 			<td>用户名：</td><td><input type="text"  name="loginName" onblur="checkloginid(this);" id="loginName" maxlength=30/><font color="red"><span id="loginidspan"></span></font>
			 			</td></tr>
			 			<tr>
			 			<td>初始密码：</td><td><input id="initpwd" type="password" name="passWord" onblur="checkpwd(this);" maxlength=30/><font color="red"><span id="pwdspan"></span></font>
			 			</td>
			 			</tr>
			 			<tr>
			 			<td>确认密码：</td><td><input type="password" name="password2" onblur="checkpwd2(this);" maxlength=30/><font color="red"><span id="pwd2span"></span></font>
			 			</tr>
			 			<tr>
			 			<td>会员类型：</td><td><select name="type"><option value="1" selected="selected">普通会员</option><option value="2">vip会员</option></select>
			 			</td></tr>
			 			<tr>
			 			<td>
			 			邮箱：</td><td><input type="text" name="email" onblur="checkEmail(this);" maxlength=30/><font color="red"><span id="emailspan"></span></font>
			 			</td></tr>
			 				
			 			
			 			<tr>
			 			<td colspan=2 class="centerTd">
			 				<input type="button"  class="button" value="注册" onclick="validate();"/><input type="reset"/>
 						</td></tr>
 				
		</tbody>

	</table>
	</form>
</div>
  
            
       
        <script type="text/javascript">
 	var namespan=document.getElementById("namespan");
 	var loginidspan=document.getElementById("loginidspan");
 	var pwdspan=document.getElementById("pwdspan");
 	var pwd2span=document.getElementById("pwd2span");
 	var yz=document.getElementById("yzspan");
 	var emailspan=document.getElementById("emailspan");
 	function checkname(obj){ 	
 	if(obj.value.length<=0){	
 	namespan.innerHTML="请输入姓名";
 	}else{
 	namespan.innerHTML="";
 	} 	
 	}
 	
 	function checkloginid(obj){ 	
 	if(obj.value.length<=0){	
 	loginidspan.innerHTML="请输入用户名";
 	
 	}else{
	
 	 $.ajax({
     		type:"post",
            url:"<%=request.getContextPath()%>/admin/member_manage/checkName",
            dataType:"text",
            data:"loginID="+obj.value, 
    
	     success: function(msg){       
	      		if(msg==2){
	      		loginidspan.innerHTML="该用户名已被注册";
	      		}else if(msg==1){
	      		loginidspan.innerHTML="";
	      		}
	       }   
		});  	
 	} 	
 	}
 	
 	
 	
 	
 	function checkpwd(obj){ 	
 	if(obj.value.length<=0){	
 	pwdspan.innerHTML="请输入密码";
 	}else{
 	pwdspan.innerHTML="";
 	} 	
 	}
 	function checkpwd2(obj){ 
 	var initpwd=document.getElementById("initpwd").value;	
 	if(obj.value.length<=0){	
 	pwd2span.innerHTML="请确认密码";
 	}else{
 	if(initpwd==obj.value){
 	pwd2span.innerHTML="";
 	}else{
 	pwd2span.innerHTML="两次密码不一样";
 	}
 	
 	} 	
 	}
 	
 	function checkyz(obj){
 	if(obj.value.length<=0){	
 	yzspan.innerHTML="请输入验证码";
 	}else{
 	
 	
 	 $.ajax({
     		type:"post",
            url:"member/checkYZM.do",
            dataType:"text",
            data:"yzm="+obj.value, 
    
	     success: function(msg){       
	      		if(msg==2){
	      		yzspan.innerHTML="验证码错误";
	      		}else if(msg==1){
	      		yzspan.innerHTML="";
	      		}
	       }   
		});  	
 	
 	
 	} 	
 	}
 	
 	
 	 	function validate(){
 	var f=document.getElementById("myform");
 	
 	
 	
 		if(document.getElementById("loginName").value.length<=0){
 	loginidspan.innerHTML="请输入用户名";
 	}else if(loginidspan.innerHTML=="该用户名已被注册"){
 	return;
 	}
 	else if(document.getElementById("initpwd").value.length<=0){
 	pwdspan.innerHTML="请输入密码";
 	}else if(document.getElementById("name").value.length<=0){
 	namespan.innerHTML="请输入姓名";
 	}else if(emailspan.innerHTML=="请输入正确的邮箱格式"){
 	return;
 	}
 	
 	
 	else{
 	
 	f.submit();
 	}
 
 	
 	}
 	
 	
 	function checkEmail(obj){
 	
 	if(obj.value.length>0){
 		  var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
 		  if(!myreg.test(obj.value)){		  
 		  emailspan.innerHTML="请输入正确的邮箱格式";
 		  }else{
 		   emailspan.innerHTML="";
 		  }
 	}if(obj.value.length<=0){
 	 emailspan.innerHTML="";
 	}
 	}
 	
 </script>
    </body>
</html>
